<?php

cload("object");
cload("database.dbquery");
/**
 * Класс по получению списка фильмов из локальной базы кинопоиска
 *
 * @author Di_Moon
 */
class kinoPoiskList {
    protected $_dbh;
    protected $_table;
    protected $_list;
    
    protected $_order;
    protected $_ordertype;
    
    protected $_limitStart;
    protected $_limitCount;
            
    function __construct($dbh, $order="id", $ordertype="asc") {
        $this->_dbh = $dbh;
        $this->_table = "filmsKinoPoisk";
        
        $this->_order = $order;
        $this->_ordertype = $ordertype;
        
        $this->_limitStart = 0;
        $this->_limitCount = 0;
    }
    
    function limit($from, $count) {
        $this->_limitStart = $from;
        $this->_limitCount = $count;
    }
    
    function getList() {
        $this->_list = array();
        $query = new dbquery($this->_dbh);
        $query->select()->from($this->_table)->order($this->_order." ".$this->_ordertype);
        if($this->_limitStart!=0 && $this->_limitCount!=0) 
            $query->limit($this->_limitStart, $this->_limitCount);
        $sth = $this->_dbh->query($query);
        
        while($fa = $this->_dbh->raw_fetch_array()) {
            array_push($this->_list, new object($fa));
        }
        
        return $this->_list;
    }
}

?>
